﻿Imports DevExpress.XtraSplashScreen
Imports DevExpress.XtraEditors

Public Class ToaThuocMau
    Public Overrides Sub setSubSau_TaoMoi()
        Me.setMacDinhCotAn("ma", "TTHM" & System.Guid.NewGuid.ToString)
        Me.TinhtrangISearchLookupEdit.EditValue = "1"
        Me.SotoathuocITextEdit.EditValue = Me.QueriesTableAdapter1.getSoToaThuoc_ToaThuocMau("TTHM", Today)
    End Sub
    Public Overrides Sub setSubTruoc_Luu()
        Me.setSuaTruocKhiLuuTab1("sotoathuoc", Me.SotoathuocITextEdit.EditValue)
    End Sub
    Private Sub LoadDuLieu()
        SplashScreenManager.ShowForm(GetType(WaitForm1))
        Me.ToaThuocMauChiTietTableAdapter.Fill(Me.PCV_CLINICDataSet.ToaThuocMauChiTiet)
        Me.ToaThuocMauTableAdapter.Fill(Me.PCV_CLINICDataSet.ToaThuocMau)
        Me.DMHangHoaTableAdapter.Fill(Me.PCV_CLINICDataSet.DMHangHoa)
        Me.DMTinhTrangTableAdapter.Fill(Me.PCV_CLINICDataSet_Don.DMTinhTrang)
        Me.DMBenhTableAdapter.Fill(Me.PCV_CLINICDataSet_Don.DMBenh)
        Me.DMBacSiTableAdapter.Fill(Me.PCV_CLINICDataSet_Don.DMBacSi)
        SplashScreenManager.CloseForm()
    End Sub
    Private Sub ToaThuocMau_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        LoadDuLieu()
    End Sub
    Public Sub New()
        InitializeComponent()
        Me.setSoTabThamChieu(0)
        Me.setSoTab(1)
        Me.setObj(Me.PCV_CLINICDataSet, Me.PCV_CLINICDataSet.ToaThuocMau, ToaThuocMauBindingSource, TableAdapterManager, ToaThuocMauTableAdapter, SotoathuocITextEdit, TinhtrangISearchLookupEdit)
        Me.setTab1(Me.PCV_CLINICDataSet.ToaThuocMauChiTiet, Me.FKToaThuocMauChiTietToaThuocMauBindingSource, Me.ToaThuocMauChiTietTableAdapter)
    End Sub
    Private Shadows Sub BarButtonItemBaoCao_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItemBaoCao.ItemClick

    End Sub

    Private Sub RepositoryItemISearchLookUpEdit_HangHoa_EditValueChanging(sender As Object, e As DevExpress.XtraEditors.Controls.ChangingEventArgs) Handles RepositoryItemISearchLookUpEdit_HangHoa.EditValueChanging
        Dim editor As SearchLookUpEdit = CType(sender, SearchLookUpEdit)
        Dim rowHandle As Integer = editor.Properties.GetIndexByKeyValue(e.NewValue)
        IGridViewChiTiet01.SetFocusedRowCellValue("mahang", editor.Properties.View.GetRowCellValue(rowHandle, "ma"))
        IGridViewChiTiet01.SetFocusedRowCellValue("tenhang", editor.Properties.View.GetRowCellValue(rowHandle, "ten"))
        IGridViewChiTiet01.SetFocusedRowCellValue("dvt", editor.Properties.View.GetRowCellValue(rowHandle, "donvitinh"))
    End Sub

    Private Sub IGridViewChiTiet01_InitNewRow(sender As Object, e As DevExpress.XtraGrid.Views.Grid.InitNewRowEventArgs) Handles IGridViewChiTiet01.InitNewRow
        Me.IGridViewChiTiet01.SetFocusedRowCellValue("uid", System.Guid.NewGuid)
        Me.IGridViewChiTiet01.SetFocusedRowCellValue("soluong", 0)
    End Sub
End Class
